//index.js
const checkCity = require('../../../utils/checkCity.js');
const api = require('../../../utils/api.js');
Page({
  data: {
    bannerlist:[
      {
        id: 1,
        url: "https://image.xuegongbang.cn/banner_1.jpg"
      },
      {
        id: 1,
        url: "https://image.xuegongbang.cn/banner_2.jpg"
      },
      {
        id: 1,
        url: "https://image.xuegongbang.cn/banner_3.jpg"
      }
    ],
    params: {
      page: 2,
    },
  },
  onLoad: function () {
    const that = this;
    if (typeof this.getTabBar === 'function' &&
      that.getTabBar()) {
      that.getTabBar().setData({
        selected: 0
      })
    }
  },
  onShow(){
    const that = this;
    getApp().globalData.get("/api/part_time/quality", {}).then(res => {
      that.data.params.page = 2;
      that.setData({
        jobList: res.data,
        params: that.data.params
      })
    })
  },
  onReachBottom() {
    const that = this;
    getApp().globalData.get("/api/part_time/quality", {
      page: that.data.params.page,
      size: 10
    }).then(res => {
      that.data.params.page = 2;
      that.setData({
        jobList: res.data,
        params: that.data.params
      })
    })
  },
  onPullDownRefresh() {
    const that = this;
    that.data.params.page = 1;
    getApp().globalData.get("/api/part_time/quality", {}).then(res => {
      that.data.params.page = 2;
      that.setData({
        jobList: res.data,
        params: that.data.params
      })
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    const that = this;
    return {
      title: that.data.jobList.title,
      path: '/pages/recruit/index/index'
    }
  }
})
